
package cn.hz.horse;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

 
 
public class EzTask  {
 
	
	private ScheduledExecutorService scheduledThreadPool  ;
	

	private ScheduledExecutorService scheduledThreadPoolSucc  ;
	

	private ScheduledExecutorService scheduledThreadPoolFail  ;
	
	public EzTask(){
		scheduledThreadPool=EzSource.scheduledThreadPool;
		scheduledThreadPoolSucc=EzSource.scheduledThreadPoolSucc;
		scheduledThreadPoolFail=EzSource.scheduledThreadPoolFail;
	}
	
	public void shutdown(){
		 scheduledThreadPool.shutdownNow();
		scheduledThreadPoolSucc.shutdownNow();
		scheduledThreadPoolFail.shutdownNow();
	}
	
	public void install(EzHandle handle){
		if(scheduledThreadPool == null){
			System.out.println(" ");
			scheduledThreadPool=Executors.newScheduledThreadPool(5); 
		}
		EzRuner runer =EzFactory.buildRuner();
		runer.setHandle(handle);
		scheduledThreadPool.execute(runer);
	}	
	
	

	public void installRes(EzResHandle handle){
		if(scheduledThreadPoolSucc == null){
			 
			scheduledThreadPoolSucc=Executors.newScheduledThreadPool(5); 
		}
		
		if(scheduledThreadPoolFail == null){
			 
			scheduledThreadPoolFail=Executors.newScheduledThreadPool(5); 
		}
		EzSuccRuner runer =EzFactory.buildSucRuner();
		runer.setHandle(handle);
		scheduledThreadPoolSucc.execute(runer);
		
		
		EzFailRuner runer2 =EzFactory.buildFailRuner();
		runer2.setHandle(handle);
		scheduledThreadPoolFail.execute(runer);
	}	

}
